{extend name="base"/}
{block name="resources"}
<style>
	.required { margin-right: 3px; }
	.ns-check-member { position: relative; }
	.ns-check-member .layui-btn { position: absolute; top: 0; right: 1px; border-color: #e5e5e5; padding: 0 10px; border-right: 0; }
	
	.ns-store-company, .ns-pay-company, .ns-pay-alipay, .ns-shop-own { display: none; }

	/* 关联会员 */
	.ns-search-result { border: 1px solid; padding: 15px 30px 15px 15px; display: flex; align-items: center; position: relative;margin-top:10px; }
	.ns-search-res-img { width: 50px; height: 50px; margin-right: 5px; text-align: center; line-height: 50px; }
	.ns-search-res-img img { max-width: 100%; max-height: 100%; }
	.ns-search-res-intro p { line-height: 24px; }
	.ns-search-res-close { position: absolute; top: 5px; right: 5px; }
	
	.ns-card-common:first-of-type {margin-top: 0;}
	.ns-form-row {margin-top: 0;}
	.ns-check-member .layui-input:focus+.layui-btn {border-color: #4685FD;}
	.ns-store-company, .ns-pay-company{margin-top: 10px;}
	#container{ width: 650px; height: 500px; }

	.upload_img_square {
		display: inline-block;
		width: 80px;
		height: 80px;
		line-height: 78px;
		font-size: 30px;
		color: #bbbbbb;
		cursor: pointer;
		border: 1px dashed #ccc;
		border-radius: 5px;
		text-align: center;
		margin-bottom: 10px;
		margin-right: 10px;
	}

	.upload_img_square_item {
		display: inline-block;
		float: left;
		width: 80px;
		height: 80px;
		position: relative;
		border: 1px dashed #e5e5e5;
		text-align: center;
		transition: background-color 0.3s ease;
		margin-bottom: 10px;
		margin-right: 10px;
	}
	.upload_img_square_item:hover {
		border: 1px dashed #ff8143;
		border-radius: 5px;
	}
	.upload_img_square_item:hover .operation {
		display: block;
	}
	.upload_img_square_item .img-wrap {
		width: 80px;
		font-size: 0;
		line-height: 79px;
		border-radius: 5px;
		overflow: hidden;
	}
	.upload_img_square_item .img-wrap img {
		width: calc(100% - 2px);
		height: calc(100% - 2px);
	}
	.upload_img_square_item .operation {
		position: absolute;
		top: 0;
		z-index: 10;
		width: 80px;
		height: 80px;
		line-height: 80px;
		background: rgba(0, 0, 0, 0.5);
		color: #fff;
		cursor: pointer;
		text-align: center;
		display: none;
	}
	.upload_img_square_item .operation i {
		font-size: 20px;
		margin-left: 10px;
	}
	.upload_img_square_item .operation i:first-child {
		margin-left: 0;
	}
	.upload_img_square_item .operation .replace_img {
		position: absolute;
		bottom: 0;
		width: 100%;
		height: 24px;
		color: #fff;
		background: rgba(0, 0, 0, 0.5);
		font-size: 12px;
		line-height: 24px;
	}
	.invoice-content-box{
		display: flex;
		flex-wrap: wrap;
	}
	.invoice-content-block .layui-form-select{margin-bottom:10px}
	.invoice-content-block .layui-form-select:last-child{margin-bottom:0}
	.invoice-content-block .item{
		position:relative;
		margin-bottom:10px;
		margin-right: 10px;
	}
	.invoice-content-block .item .layui-icon-close{font-size:12px;position:absolute;top:-8px;right:-8px;width:16px;height:16px;line-height:16px;text-align:center;color:#fff;-webkit-border-radius:10px;-moz-border-radius:10px;border-radius:10px;background:rgba(0,0,0,.3);cursor:pointer}
	.invoice-tip{color:#ff8143;padding-left:90px;}
</style>
{/block}
{block name="main"}
<div class="layui-form ns-form" lay-filter="editselffetch">
	<!-- 店铺信息 -->
	<div class="layui-card ns-card-common ns-card-brief">
		<div class="layui-card-header">
			<span class="ns-card-title">店铺信息</span>
		</div>
		<div class="layui-card-body">

			<div class="layui-form-item">
				<label class="layui-form-label"><span class="required">*</span>关联人员：</label>
				<div class="layui-input-block ns-len-mid">
					<select class="ns-category" name="member_id" lay-verify="required">
						<option value="">选择关联人员</option>
						{volist name="$member_list" id="member"}
						<option value="{$member.member_id}">{$member.nickname}/{$member.mobile}</option>
						{/volist}
					</select>
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label"><span class="required">*</span>店铺名称：</label>
				<div class="layui-input-block">
					<input name="site_name" type="text" lay-verify="required" class="layui-input ns-len-long" autocomplete="off">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label"><span class="required">*</span>店铺分类：</label>
				<div class="layui-input-block ns-len-mid">
					<select class="ns-category" name="category_id" lay-verify="required">
						<option value="">选择主营行业</option>
						{volist name="$shop_category_list" id="category"}
						<option value="{$category.category_id}">{$category.category_name}</option>
						{/volist}
					</select>
				</div>
			</div>

			<!--是否为自营-->
			<div class="layui-form-item">
				<label class="layui-form-label">是否自营：</label>
				<div class="layui-input-block" id="is_own">
					<input type="radio" name="is_own" lay-filter="is_own" value="0" title="否" checked>
					<input type="radio" name="is_own" lay-filter="is_own" value="1" title="是" >
				</div>
			</div>
			
			<!-- 商家主营等级 -->
			<div class="layui-form-item ">
				<label class="layui-form-label"><span class="required">*</span>店铺类型：</label>
				<div class="layui-input-block ns-len-mid">
					<select class="ns-group" name="group_id" lay-verify="required" lay-filter="group">
						<option value=""></option>
						{volist name="$shop_group_list" id="group"}
						<option value="{$group.group_id}" title="{$group.is_own}">{$group.group_name}</option>
						{/volist}
					</select>
				</div>
			</div>


			<!--自提点地址-->
			<div class="layui-form-item">
				<label class="layui-form-label"><span class="required">*</span>省市区：</label>
				<div class="layui-input-inline ns-len-mid area-select">
					<select name="province_id" lay-filter="province_id" lay-verify="province_id">
						<option value="">请选择省份</option>
						{foreach $province_list as $k => $v}
						<option value="{$v.id}">{$v.name}</option>
						{/foreach}
					</select>
				</div>

				<div class="layui-input-inline ns-len-mid area-select">
					<select name="city_id"  lay-filter="city_id" lay-verify="city_id">
						<option value="">请选择城市</option>
					</select>
				</div>

				<div class="layui-input-inline ns-len-mid area-select">
					<select name="district_id"  lay-filter="district_id" lay-verify="district_id">
						<option value="">请选择区/县</option>
					</select>
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label"></label>
				<div class="layui-input-block">
					<input type="text" name="address"  placeholder="请填写的具体地址。" lay-verify="required" autocomplete="off" class="layui-input ns-len-long address-content" value="">
					<input type = "hidden" name="longitude" lay-verify="required" class="layui-input"/>
					<input type = "hidden" name="latitude" lay-verify="required" class="layui-input"/>
					<button class='layui-btn-primary layui-btn' onclick="refreshFrom();">查找地址</button>
				</div>
				<div class="ns-word-aux">点击查找地址可在地图上显示输入的地理位置</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">地图定位：</label>
				<div class="layui-input-block ns-special-length">
					<div id="container" class="selffetch-map"></div>
				</div>
				<div class="ns-word-aux empty-address">请选择地理位置！在地图上点击得到的地理位置会自动填入到对应的输入框中</div>
			</div>


			<div class="layui-form-item time-type-view-all" >
				<label class="layui-form-label"><span class="required">*</span>营业时间：</label>
				<div class="layui-input-inline">
					<input type="text" class="layui-input" id="startTime" lay-verify="start_time|required" placeholder="开始时间" value="" readonly >
					<input type="hidden" class="layui-input" name="start_time" placeholder="开始时间" >
				</div>
				<div class="layui-form-mid layui-word-aux">~</div>
				<div class="layui-input-inline">
					<input type="text" class="layui-input" id="endTime" lay-verify="end_time|required" placeholder="结束时间" value="" readonly >
					<input type="hidden" class="layui-input" name="end_time" placeholder="结束时间" >
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label"><span class="required">*</span>联系人：</label>
				<div class="layui-input-block">
					<input type="text" name="name" lay-verify="required" autocomplete="off" class="layui-input ns-len-long" >
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label"><span class="required">*</span>联系电话：</label>
				<div class="layui-input-block">
					<input type="number" name="mobile" lay-verify="required" autocomplete="off" class="layui-input ns-len-long" >
				</div>
				<div class="ns-word-aux">请输入联系人手机号</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label"><span class="required">*</span>联系邮箱：</label>
				<div class="layui-input-block">
					<input type="text" name="contact_email" lay-verify="required" autocomplete="off" class="layui-input ns-len-long" >
				</div>
				<div class="ns-word-aux">请输入联系人电子邮箱</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label"><span class="required">*</span>店铺列表图片：</label>
				<div class="layui-input-block img-upload">
					<div class="upload-img-block">
						<div class="upload-img-box ">
							<div class="ns-upload-default" id="storeUpload">
								<div class="upload">
									<img src="ADMIN_IMG/upload_img.png" data-id="imgUpload"/>
									<p>点击上传</p>
								</div>
							</div>
							<div class="operation">
								<div>
									<i title="图片预览" class="iconfont iconreview js-preview" style="margin-right: 20px;"></i>
									<i title="删除图片" class="layui-icon layui-icon-delete js-delete"></i>
								</div>
								<div class="replace_img js-replace">点击替换</div>
							</div>
							<input type="hidden" name="avatar" >
						</div>
					</div>
				</div>

				<div class="ns-word-aux">建议宽度<span class="pic_width">160</span>px  建议高度<span class="pic_height">160</span>px</div>
			</div>


			<div class="layui-form-item goods-image-wrap">
				<label class="layui-form-label"><span class="required">*</span>店铺详情图片：</label>
				<div class="layui-input-block">
					<!--商品主图项-->
					<div class="js-goods-image"></div>
					<div class="item js-add-goods-image upload_img_square">+</div>
				</div>
				<!--                <div class="item js-add-goods-image upload_img_square">+</div>-->

				<input type="hidden" name="banner" value="" />
			</div>
			<!--<div class="layui-form-item ns-shop-time">
				<label class="layui-form-label"><span class="required">*</span>入驻时长：</label>
				<div class="layui-input-block ns-len-mid">
					<select name="year" lay-verify="required">
						<option value="">选择入驻时长</option>
						<option value="1">一年</option>
						<option value="2">二年</option>
						<option value="3">三年</option>
						<option value="4">四年</option>
						<option value="5">五年</option>
					</select>
				</div>
			</div>-->

		</div>
	</div>



	<!-- 企业店铺独有 -->
	<div class="ns-store-company">

		<!-- 企业信息 -->
		<div class="layui-card ns-card-common ns-card-brief">
			<div class="layui-card-header">
				<span class="ns-card-title">企业信息</span>
			</div>
			<div class="layui-card-body">
				<div class="layui-form-item">
					<label class="layui-form-label">公司名称：</label>
					<div class="layui-input-block">
						<input name="company_name" type="text" class="layui-input ns-len-long" autocomplete="off">
					</div>
				</div>

				<div class="layui-form-item" data-flag="area">
					<label class="layui-form-label">公司地址：</label>
					<div class="layui-input-inline ns-len-mid">
						<select name="company_province_id" data-type="province" data-init="" lay-filter="comProvince"></select>
					</div>
					<div class="layui-input-inline ns-len-mid">
						<select name="company_city_id" data-type="city" data-init="" lay-filter="comCity"></select>
					</div>
					<div class="layui-input-inline ns-len-mid">
						<select name="company_district_id" data-type="district" data-init="" lay-filter="comDistrict"></select>
					</div>
				</div>
				<div class="layui-form-item" data-flag="area">
					<label class="layui-form-label">详细地址：</label>
					<div class="layui-input-inline">
						<input name="company_address" type="text" placeholder="请输入详细地址" class="layui-input ns-len-mid" autocomplete="off">
					</div>
				</div>
			</div>
		</div>
	</div>

	<!-- 公共部分 -->
	<!-- 联系人信息 -->
	<div class="layui-card ns-card-common ns-card-brief">
		<div class="layui-card-header">
			<span class="ns-card-title">联系人信息</span>
		</div>
		<div class="layui-card-body">

			<div class="layui-form-item">
				<label class="layui-form-label img-upload-lable ns-company-pic-front">身份证正面：</label>
				<div class="layui-input-block">
					<div class="upload-img-block img-upload">
						<div class="upload-img-box">
							<div class="ns-upload-default" id="idCardPicFront">
								<div class="upload">
									<img src="ADMIN_IMG/upload_img.png"/>
									<p>点击上传</p>
								</div>
							</div>
							<div class="operation">
								<div>
									<i title="图片预览" class="iconfont iconreview js-preview" style="margin-right: 20px;"></i>
									<i title="删除图片" class="layui-icon layui-icon-delete js-delete"></i>
								</div>
								<div class="replace_img js-replace">点击替换</div>
							</div>
							<input type="hidden" name="contacts_card_electronic_2" value="">
						</div>
					</div>
				</div>
				<span class="ns-word-aux">上传申请人身份证正面，即有本人照片与身份证号的那一面</span>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label img-upload-lable ns-company-pic-back">身份证反面：</label>
				<div class="layui-input-block">
					<div class="upload-img-block img-upload">
						<div class="upload-img-box">
							<div class="ns-upload-default" id="idCardPicBack">
								<div class="upload">
									<img src="ADMIN_IMG/upload_img.png"/>
									<p>点击上传</p>
								</div>
							</div>
							<div class="operation">
								<div>
									<i title="图片预览" class="iconfont iconreview js-preview" style="margin-right: 20px;"></i>
									<i title="删除图片" class="layui-icon layui-icon-delete js-delete"></i>
								</div>
								<div class="replace_img js-replace">点击替换</div>
							</div>
							<input type="hidden" name="contacts_card_electronic_3" value="">
						</div>
					</div>
				</div>
				<span class="ns-word-aux">上传申请人身份证反面，即有身份登记地址的那一面</span>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label"><span class="required">*</span>证件姓名：</label>
				<div class="layui-input-block">
					<input type="text" name="contacts_card_name"  lay-verify="required" autocomplete="off" class="layui-input  ns-len-long">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label ns-company-ident">证件号码：</label>
				<div class="layui-input-inline">
					<input name="contacts_card_no" type="text" lay-verify="idcard|required" class="layui-input ns-len-long" autocomplete="off">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label"><span class="required">*</span>证件地址：</label>
				<div class="layui-input-block">
					<input type="text" name="legal_addr"  lay-verify="required" autocomplete="off" class="layui-input  ns-len-long">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label"><span class="required">*</span>证件类型：</label>
				<div class="layui-input-block ns-len-mid">
					<select name="contacts_card_type" lay-verify="required">
						<option value="">请选择证件类型</option>
						{foreach $id_card_type_list as $id_card_type_list_k => $id_card_type_list_v}
						<option value="{$id_card_type_list_v}">{$id_card_type_list_v}</option>
						{/foreach}
					</select>
				</div>
			</div>


			<div class="layui-form-item">
				<label class="layui-form-label">有效期类型：</label>
				<div class="layui-input-block" id="legal_cert_validity_type">
					<input type="radio" name="legal_cert_validity_type" lay-filter="legalCertValidityType" value="1" title="长期有效" >
					<input type="radio" name="legal_cert_validity_type" lay-filter="legalCertValidityType" value="0" title="非长期有效" checked>
				</div>
			</div>


			<div class="layui-form-item time-type-view-all" >
				<label class="layui-form-label"><span class="required">*</span>证件有效期：</label>
				<div class="layui-input-inline">
					<input type="text" class="layui-input" id="idCardStartTime" lay-verify="id_card_start_time|required" placeholder="证件有效期开始时间" value="" readonly >
					<input type="hidden" class="layui-input" name="contacts_card_start_time" placeholder="证件有效期开始时间" >
				</div>
				<div class="layui-form-mid layui-word-aux">~</div>
				<div class="layui-input-inline">
					<input type="text" class="layui-input" id="idCardEndTime" lay-verify="id_card_end_time|required" placeholder="证件有效期结束时间" value="" readonly >
					<input type="hidden" class="layui-input" name="contacts_card_end_time" placeholder="证件有效期结束时间" >
				</div>
			</div>
			<!--<div class="layui-form-item">
				<label class="layui-form-label ns-company-name">联系人姓名：</label>
				<div class="layui-input-inline">
					<input name="contacts_name" type="text" class="layui-input ns-len-long" autocomplete="off">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label ns-company-phone">联系人手机：</label>
				<div class="layui-input-block">
					<input name="contacts_mobile" type="text" lay-verify="mobile" class="layui-input ns-len-long" autocomplete="off">
				</div>
				<span class="ns-word-aux">请填写有效的手机号，如有问题可通过该手机号联系到商家</span>
			</div>-->


		</div>
	</div>

	<!-- 开户行信息 -->
	<!-- 结算信息 -->
	<div class="layui-card ns-card-common ns-card-brief">
		<div class="layui-card-header">
			<span class="ns-card-title">开户行信息</span>
		</div>
		<div class="layui-card-body">
			<div class="layui-form-item" hidden>
				<label class="layui-form-label"><span class="required">*</span>结算账户类型：</label>
				<div class="layui-input-inline ns-len-mid">
					{if in_array("bank", $support_transfer_type)}
					<input type="radio" name="bank_type" lay-filter="payType" value="1" title="银行卡" checked>
					{/if}
					{if in_array("alipay", $support_transfer_type)}
					<input type="radio" name="bank_type" lay-filter="payType" value="2" title="支付宝">
					{/if}
					{if in_array("wechatpay", $support_transfer_type)}
					<input type="radio" name="bank_type" lay-filter="payType" value="3" title="微信">
					{/if}
				</div>
			</div>
			<!--银行卡-->
			<div class="ns-pay-bank">
				<div class="layui-form-item">
					<label class="layui-form-label ns-pay-alipay-name"><span class="required">*</span>开户人：</label>
					<div class="layui-input-inline">
						<input name="settlement_bank_account_name" id="settlement_bank_account_name" lay-verify="required" type="text" value="" class="layui-input ns-len-long" autocomplete="off" lay-verify="required">
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label"><span class="required">*</span>开户行：</label>
					<div class="layui-input-inline">
						<input name="settlement_bank_name" id="settlement_bank_name" type="text" lay-verify="required"  value="" class="layui-input ns-len-long" autocomplete="off" lay-verify="required">
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label ns-pay-alipay-account"><span class="required">*</span>银行卡号：</label>
					<div class="layui-input-inline">
						<input name="settlement_bank_account_number" id="settlement_bank_account_number" lay-verify="required"  type="text" value="" class="layui-input ns-len-long" autocomplete="off" lay-verify="required">
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label"><span class="required">*</span>银行卡类型：</label>
					<div class="layui-input-block ns-len-mid">
						<select name="settlement_bank_type" lay-verify="required">
							<option value="">请选择银行卡类型</option>
							<option value="1">对公</option>
							<option value="2">对私</option>
							<option value="3">对私非法人</option>
						</select>
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label"><span class="required">*</span>银行卡图片：</label>
					<div class="layui-input-block img-upload">
						<div class="upload-img-block">
							<div class="upload-img-box ">
								<div class="ns-upload-default" id="bankUpload">
									<div class="upload">
										<img src="ADMIN_IMG/upload_img.png" data-id="imgUpload"/>
										<p>点击上传</p>
									</div>
								</div>
								<div class="operation">
									<div>
										<i title="图片预览" class="iconfont iconreview js-preview" style="margin-right: 20px;"></i>
										<i title="删除图片" class="layui-icon layui-icon-delete js-delete"></i>
									</div>
									<div class="replace_img js-replace">点击替换</div>
								</div>
								<input type="hidden" name="settlement_bank_img" >
							</div>
						</div>
					</div>
				</div>

				<!--<div class="layui-form-item" data-flag="area" hidden>
					<label class="layui-form-label"><span class="required">*</span>结算开户银行所在地：</label>
					<div class="layui-input-inline">
						<input name="settlement_bank_address" id="settlement_bank_address" type="text" value="" class="layui-input ns-len-long" autocomplete="off" lay-verify="required">
					</div>
				</div>-->
			</div>
			<!-- 支付宝 -->
			<div class="ns-pay-zfb" style="display: none">
				<div class="layui-form-item">
					<label class="layui-form-label"><span class="required">*</span>用户真实姓名：</label>
					<div class="layui-input-inline">
						<input name="zfb_settlement_bank_account_name" id="settlement_zfb_account_name" type="text" value="" class="layui-input ns-len-long" autocomplete="off">
					</div>
				</div>

				<div class="layui-form-item" data-flag="area">
					<label class="layui-form-label"><span class="required">*</span>支付宝账号：</label>
					<div class="layui-input-inline">
						<input name="zfb_settlement_bank_account_number" id="settlement_zfb_account_number" type="text" value="" class="layui-input ns-len-long" autocomplete="off">
					</div>
				</div>
			</div>
			<div class="ns-pay-win" style="display: none">
				<div class="layui-form-item">
					<label class="layui-form-label type_3_settlement_bank_account_name"><span class="required">*</span>微信绑定：</label>
					<div class="layui-input-block shop-bind">
						<div class="ns-img-box" style="height: 100px!important;width: auto;">
							<image layer-src src="{:addon_url('admin/shop/shopBindQrcode')}"/>
							<div class="img-load layui-hide">点击重新加载</div>
						</div>
					</div>
					<div class="ns-word-aux">请扫描二维码与微信绑定</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label ns-pay-alipay-name"><span class="required">*</span>用户真实姓名：</label>
					<div class="layui-input-inline">
						<input name="weixin_settlement_bank_account_name" id="weixin_settlement_bank_account_name" type="text" value="" class="layui-input ns-len-long" autocomplete="off">
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">微信昵称：</label>
					<div class="layui-input-inline">
						<input name="weixin_settlement_bank_address" type="text" value="" class="layui-input ns-len-long ns-dis-input" autocomplete="off" disabled>
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label"><span class="required">*</span>微信账号：</label>
					<div class="layui-input-inline">
						<input name="weixin_settlement_bank_name" id="weixin_settlement_bank_name"  type="text" value="" class="layui-input ns-len-long" autocomplete="off">
					</div>
				</div>
				<!-- 微信openid -->
				<input name="weixin_settlement_bank_account_number" value="" type="hidden" class="layui-input">
			</div>
		</div>
	</div>


	<!-- 申请类型 -->
	<div class="layui-card ns-card-common ns-card-brief">
		<div class="layui-card-header">
			<span class="ns-card-title">申请类型</span>
		</div>
		<div class="layui-card-body">
			<div class="layui-form-item">
				<label class="layui-form-label">申请类型：</label>
				<div class="layui-input-block" id="cert_type">
					<input type="radio" name="cert_type" lay-filter="certType" value="1" title="个人店铺" checked>
					<input type="radio" name="cert_type" lay-filter="certType" value="2" title="企业店铺" >
				</div>
			</div>
		</div>
	</div>

	<!-- 营业执照 税务 -->
	<!-- 企业店铺独有 -->
	<div class="ns-store-company">
		<div class="layui-card ns-card-common ns-card-brief">
			<div class="layui-card-header">
				<span class="ns-card-title">营业执照</span>
			</div>
			<div class="layui-card-body">


				<div class="layui-form-item">
					<label class="layui-form-label">经营类型：</label>
					<div class="layui-input-block" id="busi_type">
						<input type="radio" name="busi_type" lay-filter="busiType" value="1" title="实体" checked>
						<input type="radio" name="busi_type" lay-filter="busiType" value="2" title="虚拟" >
					</div>
				</div>


				<div class="layui-form-item">
					<label class="layui-form-label img-upload-lable">营业执照：</label>
					<div class="layui-input-block">
						<div class="upload-img-block img-upload">
							<div class="upload-img-box">
								<div class="ns-upload-default" id="license">
									<div class="upload">
										<img src="ADMIN_IMG/upload_img.png"/>
										<p>点击上传</p>
									</div>
								</div>
								<div class="operation">
									<div>
										<i title="图片预览" class="iconfont iconreview js-preview" style="margin-right: 20px;"></i>
										<i title="删除图片" class="layui-icon layui-icon-delete js-delete"></i>
									</div>
									<div class="replace_img js-replace">点击替换</div>
								</div>
								<input type="hidden" name="business_licence_number_electronic" value="">
							</div>
						</div>
					</div>
					<span class="ns-word-aux">请上传营业执照传真图片或者照片，营业执照包括边框内容要全部显示，不能遮挡</span>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">统一社会信用码：</label>
					<div class="layui-input-block">
						<input name="business_licence_number" type="text" class="layui-input ns-len-long" autocomplete="off">
					</div>
					<span class="ns-word-aux">请填写三证合一之后的营业执照上的统一社会信用代码</span>
				</div>

				<div class="layui-card-body">
					<div class="layui-form-item">
						<label class="layui-form-label">有效期类型：</label>
						<div class="layui-input-block" id="license_time_type">
							<input type="radio" name="license_time_type" lay-filter="licenseTimeType" value="1" title="长期有效" >
							<input type="radio" name="license_time_type" lay-filter="licenseTimeType" value="0" title="有期限" checked>
						</div>
					</div>
				</div>

				<div class="layui-form-item" id="license_time">
					<label class="layui-form-label">证件有效期：</label>
					<div class="layui-input-inline">
						<input type="text" class="layui-input" id="businessLicenseStartTime" lay-verify="business_license_start_time" placeholder="营业执照开始时间" value="" readonly >
						<input type="hidden" class="layui-input" name="license_start_date" placeholder="开始日期" >
					</div>
					<div class="layui-form-mid layui-word-aux">~</div>
					<div class="layui-input-inline">
						<input type="text" class="layui-input" id="businessLicenseEndTime" lay-verify="business_license_end_time" placeholder="营业执照结束时间" value="" readonly >
						<input type="hidden" class="layui-input" name="license_end_date" placeholder="结束日期" >
					</div>
				</div>

				<div class="layui-form-item" hidden>
					<label class="layui-form-label">法定经营范围：</label>
					<div class="layui-input-block ns-len-long">
						<textarea name="business_sphere" class="layui-textarea"></textarea>
					</div>
					<span class="ns-word-aux">经营范围（可填写营业执照上的经营范围内容）</span>
				</div>

				<!-- <div class="layui-form-item">
					<label class="layui-form-label">税务登记证号：</label>
					<div class="layui-input-block">
						<input name="tax_registration_certificate" type="text" class="layui-input ns-len-long" autocomplete="off">
					</div>
					<span class="ns-word-aux">税务登记证号即为三证合一之后的营业执照上的统一社会信用代码，三证合一之前为税务登记证上的编码</span>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label img-upload-lable">税务登记证电子版：</label>
					<div class="layui-input-block img-upload">
						<div class="upload-img-box">
							<div class="ns-upload-default" id="taxlicense">
								<div class="upload">
									<img src="ADMIN_IMG/upload_img.png"/>
									<p>点击上传</p>
								</div>
							</div>
							<div class="operation">
								<div>
									<i title="图片预览" class="iconfont iconreview js-preview" style="margin-right: 20px;"></i>
									<i title="删除图片" class="layui-icon layui-icon-delete js-delete"></i>
								</div>
								<div class="replace_img js-replace">点击替换</div>
							</div>
							<input type="hidden" class="layui-input" name="tax_registration_certificate_electronic" />
						</div>
					</div>
					<span class="ns-word-aux">税务登记证传真图片或者照片，包括边框在内的内容都需要显示</span>
				</div> -->
			</div>
		</div>
	</div>

	<!-- 身份证件 -->
	<!--<div class="layui-card ns-card-common ns-card-brief">
		<div class="layui-card-header">
			<span class="ns-card-title">联系人身份证件</span>
		</div>
		<div class="layui-card-body">
			<div class="layui-form-item">
				<label class="layui-form-label ns-company-ident">联系人身份证号：</label>
				<div class="layui-input-inline">
					<input name="contacts_card_no" type="text" lay-verify="idcard" class="layui-input ns-len-long" autocomplete="off">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label img-upload-lable ns-company-pic-front">申请人身份证正面：</label>
				<div class="layui-input-block">
					<div class="upload-img-block img-upload">
						<div class="upload-img-box">
							<div class="ns-upload-default" id="idCardPicFront">
								<div class="upload">
									<img src="ADMIN_IMG/upload_img.png"/>
									<p>点击上传</p>
								</div>
							</div>
							<div class="operation">
								<div>
									<i title="图片预览" class="iconfont iconreview js-preview" style="margin-right: 20px;"></i>
									<i title="删除图片" class="layui-icon layui-icon-delete js-delete"></i>
								</div>
								<div class="replace_img js-replace">点击替换</div>
							</div>
							<input type="hidden" name="contacts_card_electronic_2" value="">
						</div>
					</div>
				</div>
				<span class="ns-word-aux">上传申请人身份证正面，即有本人照片与身份证号的那一面</span>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label img-upload-lable ns-company-pic-back">申请人身份证反面：</label>
				<div class="layui-input-block">
					<div class="upload-img-block img-upload">
						<div class="upload-img-box">
							<div class="ns-upload-default" id="idCardPicBack">
								<div class="upload">
									<img src="ADMIN_IMG/upload_img.png"/>
									<p>点击上传</p>
								</div>
							</div>
							<div class="operation">
								<div>
									<i title="图片预览" class="iconfont iconreview js-preview" style="margin-right: 20px;"></i>
									<i title="删除图片" class="layui-icon layui-icon-delete js-delete"></i>
								</div>
								<div class="replace_img js-replace">点击替换</div>
							</div>
							<input type="hidden" name="contacts_card_electronic_3" value="">
						</div>
					</div>
				</div>
				<span class="ns-word-aux">上传申请人身份证反面，即有身份登记地址的那一面</span>
			</div>
		</div>
	</div>-->

	<!-- 对公账户信息 -->
	<!-- 企业店铺独有 -->
	<!--<div class="ns-pay-company">
		<div class="layui-card ns-card-common ns-card-brief">
			<div class="layui-card-header">
				<span class="ns-card-title">对公账户</span>
			</div>
			<div class="layui-card-body">
				<div class="layui-form-item">
					<label class="layui-form-label"><span class="required">*</span>银行开户名：</label>
					<div class="layui-input-block">
						<input name="bank_account_name" type="text" class="layui-input ns-len-long" autocomplete="off">
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label"><span class="required">*</span>公司银行账号：</label>
					<div class="layui-input-inline">
						<input name="bank_account_number" type="text" class="layui-input ns-len-long" autocomplete="off">
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label"><span class="required">*</span>开户银行名称：</label>
					<div class="layui-input-inline">
						<input name="bank_name" type="text" class="layui-input ns-len-long" autocomplete="off">
					</div>
				</div>
				
				<div class="layui-form-item" data-flag="area">
					<label class="layui-form-label"><span class="required">*</span>开户银行所在地：</label>
					<div class="layui-input-inline ns-len-mid">
						<select class="bank-province" data-type="province" data-init="" lay-filter="bankProvince"></select>
					</div>
					<div class="layui-input-inline ns-len-mid">
						<select class="bank-city" data-type="city" data-init="" lay-filter="bankCity"></select>
					</div>
					<div class="layui-input-inline ns-len-mid">
						<select class="bank-district" data-type="district" data-init="" lay-filter="bankDistrict"></select>
					</div>
				</div>
			</div>
		</div>
	</div>-->

	<div class="layui-card ns-card-common ns-card-brief">
		<div class="layui-card-header">
			<span class="ns-card-title">其他</span>
		</div>
		<div class="layui-card-body">
			<div class="layui-form-item">
				<label class="layui-form-label"><span class="required">*</span>排序：</label>
				<div class="layui-input-ns">
					<input name="sort" type="number" lay-verify="required" value="10" class="layui-input ns-len-long" autocomplete="off">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label"><span class="required">*</span>抽佣比例：</label>
				<div class="layui-input-ns">
					<input name="commission_rate" type="number" lay-verify="required" value="10" class="layui-input ns-len-long" autocomplete="off">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">推荐首页：</label>
				<div class="layui-input-block">
					<input type="radio" name="is_recommend" value="1" title="是" lay-filter="is_recommend" checked>
					<input type="radio" name="is_recommend" value="0" title="否" lay-filter="is_recommend" >
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">人均：</label>
				<div class="layui-input-ns">
					<input name="per_head" type="number" lay-verify="required" value="0" class="layui-input ns-len-long" autocomplete="off">
				</div>
			</div>


			<div class="layui-form-item invoice-content-block">
				<label class="layui-form-label">标签：</label>
				<div class="layui-input-inline invoice-content-box">
					<div class="item">
						<input type="text" name="shop_label[]" lay-verify="required" value="" placeholder="标签"  autocomplete="off" class="layui-input ns-len-short" >
						<i class="layui-icon layui-icon-close"></i>
					</div>
				</div>
				<a class="layui-btn layui-btn-primary add-invoice-content-button">添加</a>
			</div>
		</div>
	</div>

	<!-- 个人信息 -->
	<div class="layui-card ns-card-common ns-card-brief">
		<div class="layui-card-header">
			<span class="ns-card-title">用户信息</span>
		</div>
		<div class="layui-card-body">
			<div class="layui-form-item">
				<label class="layui-form-label"><span class="required">*</span>商家登录用户名：</label>
				<div class="layui-input-ns">
					<input name="username" type="text" lay-verify="required" class="layui-input ns-len-long" autocomplete="off">
				</div>
				<span class="ns-word-aux">用于登录商家后台</span>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label"><span class="required">*</span>商家登录密码：</label>
				<div class="layui-input-inline">
					<input name="password" type="text" lay-verify="required" class="layui-input ns-len-long" autocomplete="off">
				</div>
			</div>
		</div>
	</div>

	<div class="ns-single-filter-box">
		<div class="ns-form-row">
			<button class="layui-btn ns-bg-color" lay-submit lay-filter="save">保存</button>
			<button class="layui-btn layui-btn-primary" onclick="back()">返回</button>
		</div>
	</div>
	
	<!-- 隐藏域 -->
<!--	<input type="hidden" name="contacts_card_electronic_2" />   &lt;!&ndash; 身份证正面 &ndash;&gt;-->
<!--	<input type="hidden" name="contacts_card_electronic_3" />   &lt;!&ndash; 身份证反面 &ndash;&gt;-->
<!--	<input type="hidden" name="business_licence_number_electronic" />   &lt;!&ndash; 营业执照电子版 &ndash;&gt;-->
	<!-- <input type="hidden" name="tax_registration_certificate_electronic" /> -->   <!-- 税务登记证号电子版 -->
</div>

<!--详情图片-->
<script type="text/html" id="houseNumberImage">
	{{# if(d.list.length){ }}
	{{# for(var i=0;i<d.list.length;i++){ }}
	<div class="item upload_img_square_item" data-index="{{i}}">
		<div class="img-wrap">
			<img src="{{ns.img(d.list[i])}}" layer-src>
		</div>
		<div class="operation">
			<i title="图片预览" class="iconfont iconreview js-preview"></i>
			<i title="删除图片" class="layui-icon layui-icon-delete js-delete" data-index="{{i}}"></i>
			<!--            <div class="replace_img img_show" data-index="{{i}}">点击替换</div>-->
		</div>
	</div>
	{{# } }}

	{{# } }}

</script>
{/block}
{block name="script"}
<script type="text/javascript">
	window._AMapSecurityConfig = {
		securityJsCode:'32f0302062f41190e845f1ab073cda3b',
	}
</script>
<script type="text/javascript" src="{:get_http_type()}://webapi.amap.com/maps?v=1.4.6&amp;key={if empty($map_key['gaode_map_key'])}af48136f5a3f33efe58cb118e0ea139c{else/}{$map_key['gaode_map_key']}{/if}"></script>
<!--<script type="text/javascript" src="{:get_http_type()}://webapi.amap.com/maps?v=1.4.6&amp;key={if empty($map_key['gaode_map_key'])}2df5711d4e2fd9ecd1622b5a53fc6b1d{else/}{$map_key['gaode_map_key']}{/if}"></script>-->
<script type="text/javascript" src="SHOP_JS/address.js"></script>
<script type="text/javascript" src="STATIC_JS/map_address.js"></script>
<script src="ADMIN_JS/address.js"></script>
<script src="__STATIC__/ext/drag-arrange.js"></script>
<script>
	var houseNumberImage = [];//详情图片
	var map_class;
	const GOODS_IMAGE_MAX = 8;//商品主图数量
	var laytpl;
	layui.use(['form','laydate','upload','laytpl'], function() {
		laytpl = layui.laytpl;
		var upload = layui.upload;
		var laydate = layui.laydate;
		var form = layui.form,
			$ = layui.jquery,
			payType = 1, //结算类型
			autotrophy = 0,//自营类型
			repeat_flag = false; //防重复标识

		//地图展示
		map_class = new mapClass("container",{lat:'',lng:''});

		form.render();

		upload.render({
			elem: '.js-add-goods-image' //绑定元素
			,url:ns.url('admin/upload/upload')
			,accept: 'images' //上传图片
			,multiple: true //允许多文件上传
			,before: function(obj){
				//do something
				console.error(obj)
			}
			,done: function(res){
				console.error(res)
				//上传完毕回调
				if(res.code > 0){ //假设成功返回的code为0
					if (houseNumberImage.length < GOODS_IMAGE_MAX) houseNumberImage.push(res.data.pic_path);
					refresHouseNumberImage();
				}
			}
			,error: function(){
				//请求出错处理
			}
		});

		var store_upload = new Upload({
			elem: '#storeUpload',
			url: ns.url("admin/upload/upload"),
		});

		var bank_upload = new Upload({
			elem: '#bankUpload',
			url: ns.url("admin/upload/upload"),
		});

		//时间选择器
		laydate.render({
			elem: '#startTime'
			, type: 'time'
			,value: ""
			,format:'HH:mm'
			,done: function(value, date, endDate){
				var time = date.hours * 3600 + date.minutes * 60 + date.seconds;
				$("input[name=start_time]").val(time);
			}
		});
		//时间选择器
		laydate.render({
			elem: '#endTime'
			, type: 'time'
			,value: ""
			,format:'HH:mm'
			,done: function(value, date, endDate){
				var time = date.hours * 3600 + date.minutes * 60 + date.seconds;
				$("input[name=end_time]").val(time);
			}
		});

		laydate.render({
			elem: '#idCardStartTime',
			type: 'date',
			value: '',
			format:'yyyy-MM-dd',
			done: function(value) {
				$("input[name=contacts_card_start_time]").val(value);
			}
		});

		laydate.render({
			elem: '#idCardEndTime',
			type: 'date',
			value: '',
			format:'yyyy-MM-dd',
			done: function(value) {
				$("input[name=contacts_card_end_time]").val(value);
			}
		});


		laydate.render({
			elem: '#businessLicenseStartTime',
			type: 'date',
			value: '',
			format:'yyyy-MM-dd',
			done: function(value) {
				$("input[name=license_start_date]").val(value);
			}
		});

		laydate.render({
			elem: '#businessLicenseEndTime',
			type: 'date',
			value: '',
			format:'yyyy-MM-dd',
			done: function(value) {
				$("input[name=license_end_date]").val(value);
			}
		});

		initArea(form); //三级联动初始化

		// 申请人身份证正面
		var idCardPicFront_upload = new Upload({
			elem: '#idCardPicFront',
			url: ns.url("admin/upload/upload")
		});

		// 申请人身份证反面
		var idCardPicBack_upload = new Upload({
			elem: '#idCardPicBack',
			url: ns.url("admin/upload/upload")
		});

		// 营业执照电子版
		var license_upload = new Upload({
			elem: '#license',
			url: ns.url("admin/upload/upload")
		});
		
		//税务登记证电子版
		var taxlicense = new Upload({
			elem: '#taxlicense',
			url: ns.url("admin/upload/upload")
		});

		form.on('submit(save)', function(data) {

			if( data.field.longitude == "" || data.field.latitude == ""){
				layer.msg('请确认地理位置!');
				$(".empty-address").show();
				return;
			}else{
				$(".empty-address").hide();
			}

			/*var full_address  = [];
			full_address.push($("select[name=province_id] option:selected").text());
			full_address.push($("select[name=city_id] option:selected").text());
			full_address.push($("select[name=district_id] option:selected").text());*/
			var province_name = $("select[name=province_id] option:selected").text();
			var city_name = $("select[name=city_id] option:selected").text();
			var district_name = $("select[name=district_id] option:selected").text();

			data.field.province = data.field.province_id;
			data.field.city = data.field.city_id;
			data.field.district = data.field.district_id;


			//地址name
			data.field.province_name = province_name;
			data.field.city_name = city_name;
			data.field.district_name = district_name;

			data.field.full_address = province_name + city_name + district_name;
			//data.field.full_address = full_address.toString();
			data.field.banner = houseNumberImage.toString();


			var bank_address = '', settlement_bank_address = '';

			data.field.category_name = $("select[name=category_id] option:selected").text();
			data.field.group_name = $("select[name=group_id] option:selected").text();
			/*if(autotrophy == 0){
				data.field.group_name = $("select[name=no_group_id] option:selected").text();
				data.field.group_id = data.field.no_group_id;
			}*/

			//对公账户
			/*bank_address += $("select[lay-filter=bankProvince] option:selected").text();
			bank_address += $("select[lay-filter=bankCity] option:selected").text();
			bank_address += $("select[lay-filter=bankDistrict] option:selected").text();
			data.field.bank_address = bank_address;*/
			//结算账户
			bankType = data.field.bank_type;
			/*if(parseInt(bankType) == 2){
				data.field.settlement_bank_account_name = data.field.zfb_settlement_bank_account_name;
				data.field.settlement_bank_account_number = data.field.zfb_settlement_bank_account_number;
				data.field.settlement_bank_address = "";
				data.field.settlement_bank_name = "";
			}else if(parseInt(bankType) == 3){
				if (!data.field.weixin_settlement_bank_account_number){
					layer.msg("请先与微信进行绑定");
					return false;
				}
				data.field.settlement_bank_account_name = data.field.weixin_settlement_bank_account_name;
				data.field.settlement_bank_account_number = data.field.weixin_settlement_bank_account_number; //openid
				data.field.settlement_bank_address = data.field.weixin_settlement_bank_address;
				data.field.settlement_bank_name = data.field.weixin_settlement_bank_name;
			}*/

			if (repeat_flag) return false;
			repeat_flag = true;
			
			//删除图片
			if(!data.field.contacts_card_electronic_2) idCardPicFront_upload.delete();
			if(!data.field.contacts_card_electronic_3) idCardPicBack_upload.delete();
			if(!data.field.business_licence_number_electronic) license_upload.delete();
			if(!data.field.avatar) store_upload.delete();
			if(!data.field.settlement_bank_img) bank_upload.delete();
			//添加
			$.ajax({
				type: 'POST',
				url: ns.url("admin/localshop/addShop"),
				data: data.field,
				dataType: 'JSON',
				success: function(res) {
					repeat_flag = false;
					if (res.code == 0) {
						layer.confirm('添加成功', {
							title:'操作提示',
							btn: ['返回列表', '继续添加'],
							yes: function(){
								location.href = ns.url("admin/localshop/lists")
							},
							btn2: function() {
								location.href = ns.url("admin/localshop/addShop")
							}
						});
					} else {
						layer.msg(res.message);
					}
				}
			});
		});

		/**
		 * select监听
		 */
		form.on('radio(is_own)', function(data) { //店铺等级中如果is_own=1，则入驻时长可以不填，否则必选
			autotrophy = data.value;
			//判断入驻时长是否必填,如果分组is_own=1 不必填 0 必填
			if (autotrophy == 0) {
				$(".ns-shop-time").show();
				$(".ns-shop-is-own").show();
				$(".ns-shop-own").hide();
				$(".ns-shop-time select").attr("lay-verify", "required");
				$(".ns-shop-is-own .ns-group").attr("lay-verify", "required");
				$(".ns-shop-own .ns-group").removeAttr("lay-verify");
			} else {
				$(".ns-shop-time").hide();
				$(".ns-shop-is-own").hide();
				$(".ns-shop-own").show();
				$(".ns-shop-time select").removeAttr("lay-verify");
				$(".ns-shop-is-own .ns-group").removeAttr("lay-verify");
				$(".ns-shop-own .ns-group").attr("lay-verify", "required");
			}
		});


		form.on('radio(licenseTimeType)', function(data){
			var value = data.value;

			if (value == 1){
				$("#license_time").hide();
			} else {
				$("#license_time").show();
			}
		});


		form.on('radio(certType)', function(data) { //为企业店铺时，显示企业独有部分，否则隐藏
			var value = data.value;
			if (value == 1) {
				$(".ns-store-company").hide();
				$(".ns-pay-company").hide();
				$(".ns-company-person").text("联系人信息");
				$(".ns-company-name").text("联系人姓名");
				$(".ns-company-phone").text("联系人电话");
				$(".ns-company-identity").text("联系人身份证件");
				$(".ns-company-ident").text("联系人身份证号");
				$(".ns-company-pic-front").text("申请人身份证正面");
				$(".ns-company-pic-back").text("申请人身份证反面");
			} else {
				$(".ns-store-company").show();
				$(".ns-pay-company").show();
				$(".ns-company-person").text("法人代表信息：");
				$(".ns-company-name").text("法人姓名：");
				$(".ns-company-phone").text("法人联系电话：");
				$(".ns-company-identity").text("法人身份证件：");
				$(".ns-company-ident").text("法人身份证号：");
				$(".ns-company-pic-front").text("法人身份证正面：");
				$(".ns-company-pic-back").text("法人身份证反面：");
			}
		});

		form.on('radio(payType)', function(data) { //判断支付方式，显示对应的表单
			payType = data.value;
			if (payType == 1) {
				$(".ns-pay-zfb").hide();
				$(".ns-pay-bank").show();
				$(".ns-pay-win").hide();

				$("#settlement_bank_account_name").attr("lay-verify", "required");
				$("#settlement_bank_account_number").attr("lay-verify", "required");
				$("#settlement_bank_name").attr("lay-verify", "required");
				$("#settlement_bank_address").attr("lay-verify", "required");

				$("#settlement_zfb_account_name").attr("lay-verify", "");
				$("#settlement_zfb_account_number").attr("lay-verify", "");

				$("#weixin_settlement_bank_account_name").attr("lay-verify", "");
				$("#weixin_settlement_bank_name").attr("lay-verify", "");
				form.render("select");
			} else if(payType == 2){
				$(".ns-pay-zfb").show();
				$(".ns-pay-bank").hide();
				$(".ns-pay-win").hide();

				$("#settlement_zfb_account_name").attr("lay-verify", "required");
				$("#settlement_zfb_account_number").attr("lay-verify", "required");

				$("#settlement_bank_name").attr("lay-verify", "");
				$("#settlement_bank_address").attr("lay-verify", "");
				$("#settlement_bank_account_name").attr("lay-verify", "");
				$("#settlement_bank_account_number").attr("lay-verify", "");

				$("#weixin_settlement_bank_account_name").attr("lay-verify", "");
				$("#weixin_settlement_bank_name").attr("lay-verify", "");
			}else if(payType == 3){
				$(".ns-pay-win").show();
				$(".ns-pay-bank").hide();
				$(".ns-pay-zfb").hide();

				$("#settlement_bank_account_name").attr("lay-verify", "");
				$("#settlement_bank_account_number").attr("lay-verify", "");
				$("#settlement_bank_name").attr("lay-verify", "");
				$("#settlement_bank_address").attr("lay-verify", "");

				$("#settlement_zfb_account_name").attr("lay-verify", "");
				$("#settlement_zfb_account_number").attr("lay-verify", "");

				$("#weixin_settlement_bank_account_name").attr("lay-verify", "required");
				$("#weixin_settlement_bank_name").attr("lay-verify", "required");

				var intervalId;
				shopBind();

				function shopBind() {
					intervalId = window.setInterval(
							function () {
								$.ajax({
									async: 'false',
									type: 'POST',
									dataType: 'JSON',
									url: "{:url('admin/shop/checkShopBind')}",
									success: function (res) {
										if (res.code == -10001 && res.data.is_expire == 1){
											$(".ns-pay-win .img-load").removeClass("layui-hide");
											clearInterval(intervalId);
											return false;
										}

										if (res.code >= 0){
											$(".ns-pay-win .img-load").removeClass("layui-hide");
											$(".ns-pay-win .img-load").html('恭喜您绑定成功！<p class="ns-text-color">重新绑定</p>');
											$("input[name='weixin_settlement_bank_account_number']").val(res.data.openid)
											$(".weixin-nickname input").val(res.data.userinfo.nickName);
											$(".weixin-nickname").attr("data-state", res.code);
											$(".weixin-nickname").removeClass("layui-hide");
											clearInterval(intervalId);
											return false;
										}
									}
								});
							}, 500
					);
				}

				$('body').on("click",".ns-pay-win .img-load",function () {
					if(parseInt($(".weixin-nickname").attr("data-state")) >= 0){
						$(".weixin-nickname").addClass("layui-hide");
					}
					$(".ns-pay-win img").attr('src',"{:addon_url('admin/shop/shopBindQrcode')}?time="+ Math.random());
					$(".ns-pay-win .img-load").addClass("layui-hide");
					shopBind();
				});
			}
		});

		/**
		 * 表单验证
		 */
		form.verify({
			/*required : function(value, item){
				var msg = $(item).attr("placeholder") != undefined ? $(item).attr("placeholder") : '';
				if(value == '') return msg;
			},*/
			province_id : function(value, item){
				if(value == ''){
					return '请选择省份';
				}
			},
			city_id : function(value, item){
				if(value == ''){
					return '请选择城市';
				}
			},
			district_id : function(value, item){
				if(value == ''){
					return '请选择区/县';
				}
			},
			mobile: function(value) {
				var reg = /^1([38][0-9]|4[579]|5[0-3,5-9]|6[6]|7[0135678]|9[89])\d{8}$/;
				if (value == '') {
					return;
				}
				if (!reg.test(value)) {
					return '请输入正确的手机号码!';
				}
			},
			idcard: function(value) {
				var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
				if (value == '') {
					return;
				}
				if (!reg.test(value)) {
					return '请输入正确的身份证号!';
				}
			},
			bankprovince: function(value){
				if (value == -1) return '请选择省';
			},
			bankcity: function(value){
				if (value == -1) return '请选择市';
			},
			bankdistrict: function(value, item){
				if (value == -1 && $(item).find('option').length > 1) return '请选择区县';
			},
		});

	});
	
	/**
	 * 点击搜索
	 */
	var repeat_flag = false;
	var html, val;

	function checkMember() {
		var parent = $(".ns-check-member");
		var con = parent.find(".ns-member-name").val();
		$(".layui-word-aux").remove();
		$(".ns-search-result").remove();

		if (repeat_flag) return false;
		repeat_flag = true;

		if (con == "" || con == null || con.trim() == "") {
			repeat_flag = false;
		} else {
			$.ajax({
				type: 'POST',
				url: ns.url("admin/member/searchMember"),
				data: {
					'search_text': con
				},
				dataType: 'JSON',
				success: function(res) {
					layer.msg(res.message);
					repeat_flag = false;

					if (res.data == null) {
						html = '<span class="layui-word-aux">未找到该用户</span>';
						val = res.data;
					} else {
						html = '<div class="ns-search-result layui-input-inline ns-border-color-gray">' +
							'<div class="ns-search-res-img">' +
							'<img src="' + ns.img(res.data.headimg) + '" />' +
							'</div>' +
							'<div class="ns-search-res-intro">' +
							'<p>用户名：' + res.data.username + '</p>' +
							'<p>电话：' + res.data.mobile + '</p>' +
							'</div>' +
							'<div class="ns-search-res-close" onclick="closeMember()">' +
							'<i class="iconfont iconclose_light"></i>' +
							'</div>' +
							'</div>';
						val = res.data.member_id;
					}

					$(".ns-member-id").attr("value", val);
					$(".ns-check-member").append(html);
				}
			});
		}
	}

	function closeMember() {
		$(".ns-search-result").hide();
	}
	
	function back() {
		location.href = ns.url("admin/localshop/lists");
	}

	/**
	 * 重新渲染表单
	 */
	function refreshFrom(){
		form.render();
		orderAddressChange();//改变地址
		map_class.mapChange();
	}

	//动态改变订单地址赋值
	function orderAddressChange(){
		map_class.address.province = $("select[name=province_id]").val();
		map_class.address.province_name = $("select[name=province_id] option:selected").text();
		map_class.address.city = $("select[name=city_id]").val();
		map_class.address.city_name = $("select[name=city_id] option:selected").text();
		map_class.address.district = $("select[name=district_id]").val();
		map_class.address.district_name = $("select[name=district_id] option:selected").text();
		map_class.address.address = $("input[name=address]").val()
	}

	/**
	 * 地址下拉框（主要用于坐标记录）
	 */
	function selectCallBack(){
		$("input[name=longitude]").val(map_class.address.longitude);//坐标
		$("input[name=latitude]").val(map_class.address.latitude);//坐标
	}

	//地图点击回调事件
	function mapChangeCallBack(){
		$("input[name=address]").val(map_class.address.address);//详细地址
		$("input[name=longitude]").val(map_class.address.longitude);//坐标
		$("input[name=latitude]").val(map_class.address.latitude);//坐标

		$.ajax({
			type : "POST",
			dataType: 'JSON',
			url : ns.url("shop/address/getGeographicId"),
			async : true,
			data : {
				"address" : map_class.address.area
			},
			success : function(data) {
				map_class.address.province = data.province_id;
				map_class.address.city = data.city_id;
				map_class.address.district = data.district_id;
				map_class.address.township = data.subdistrict_id;
				map_class.map_change = false;
				form.val("editselffetch", {
					"province_id": data.province_id
				});
				$("select[name=province_id]").change();
				form.val("editselffetch", {
					"city_id": data.city_id
				});
				$("select[name=city_id]").change();
				form.val("editselffetch", {
					"district_id": data.district_id
				});
				refreshFrom();//重新渲染form
				map_class.map_change = true;
			}
		});
	}

	//渲染门牌号主图列表
	function refresHouseNumberImage() {
		var goods_image_template = $("#houseNumberImage").html();
		var data = {
			list: houseNumberImage,
			max: GOODS_IMAGE_MAX
		};

		laytpl(goods_image_template).render(data, function (html) {

			$(".js-goods-image").html(html);

			//加载图片放大
			loadImgMagnify();

			if (houseNumberImage.length) {

				//预览
				$(".js-goods-image .js-preview").click(function () {
					$(this).parent().prev().find("img").click();
				});

				//图片删除
				$(".js-goods-image .js-delete").click(function () {
					var index = $(this).attr("data-index");
					houseNumberImage.splice(index, 1);
					refresHouseNumberImage();
				});

				// 拖拽
				$('.js-goods-image .upload_img_square_item').arrangeable({
					//拖拽结束后执行回调
					callback: function (e) {
						var indexBefore = $(e).attr("data-index");//拖拽前的原始位置
						var indexAfter = $(e).index();//拖拽后的位置
						var temp = houseNumberImage[indexBefore];
						houseNumberImage[indexBefore] = houseNumberImage[indexAfter];
						houseNumberImage[indexAfter] = temp;
						refresHouseNumberImage();
					}
				});
			}

			//最多传十张图
			if (houseNumberImage.length < GOODS_IMAGE_MAX) {
				$(".js-add-goods-image").show();
			} else {
				$(".js-add-goods-image").hide();
			}


		});
	}

	//添加发票内容
	$(".add-invoice-content-button").click(function () {
		var html = '';
		html += '<div class="item">';
		html += '<input type="text" name="shop_label[]" lay-verify="required" value="" placeholder="标签"  autocomplete="off" class="layui-input ns-len-short" >';
		html += '<i class="layui-icon layui-icon-close" ></i>';
		html += '</div>';
		$(".invoice-content-box").append(html);
	});
	//删除发票内容
	$('.invoice-content-block ').on('click', ".layui-icon-close",function () {
		$(this).parent().remove();
	});
</script>
{/block}